#ifndef LOGINWIDGET_H
#define LOGINWIDGET_H

#include"verifycodewidget.h"

#include <QWidget>
#include<QLabel>
#include<QPushButton>
#include<QLineEdit>
#include<QGridLayout>



class PhoneLoginWidget : public QWidget
{
    Q_OBJECT
public:
    explicit PhoneLoginWidget(QWidget *parent = nullptr);
private:

    //通过网络发送验证码
    void sendVerifyCode();

    //提示请求发送成功
    void sendVerifyCodeDone();

    //登录
    void clickSubmitBtn();
    void phoneLoginDone(bool ok, const QString& reason);
    void phoneRegisterDone(bool ok, const QString& reason);

    bool isLoginMode;
    QLabel* tipLabel;
    QLineEdit* phoneEdit;
    QLineEdit* verifyCodeEdit;
    QPushButton* verifyCodeBtn;
    QPushButton* submitBtn;
    QPushButton* switchToUsernameBtn;
    QPushButton* switchModeBtn;
    QTimer* timer;
    int leftTime;

private slots:
    void switchMode();
    void switchToUsername();
};

/////////////////////////////
///登录界面
/////////////////////////////
class LoginWidget : public QWidget
{
    Q_OBJECT
public:
    LoginWidget(QWidget* parent = nullptr);
private:
    QLabel* tipLabel;
    QLineEdit* usernameEdit;
    QLineEdit* passwordEdit;
    QLineEdit* verifyCodeEdit;
    VerifyCodeWidget* verifyCodeWidget;
    QPushButton* submitBtn;
    QPushButton* phoneModeBtn;
    QPushButton* switchModeBtn;

    // 是否是登录模式
    bool isLoginMode;
    // 切换注册/登录
    void switchMode();
    // 切换到电话登录模式
    void switchToPhone();

    //登录
    void clickSubmitBtn();

    //用户登录
    void userLoginDone(bool ok, const QString& reason);

    //用户注册
    void userRegisterDone(bool ok, const QString& reason);
};



#endif // LOGINWIDGET_H
